package com.example.g5project.repository.repo;

import com.example.g5project.entity.frontEndObject.FigureData;
import com.example.g5project.entity.frontEndObject.FigureData2;
import com.example.g5project.entity.frontEndObject.NewChat;
import com.example.g5project.repository.dao.FigureData2Dao;
import com.example.g5project.repository.dao.FigureDataDao;
import com.example.g5project.repository.dao.NewChatDao;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;

/**
 * @author Hu Zirui
 * @version 1.0.0
 * @ClassName AdministratorRepo.java
 * @Description TODO
 * @createTime 2022年03月23日 14:26:00
 */
@Component
@Transactional
public class NewChatRepo extends Repo<NewChat, Integer> {
    private final NewChatDao newChatDao;
    private final FigureDataDao figureDataDao;
    private final FigureData2Dao figureData2Dao;

    protected NewChatRepo(@Qualifier("newChatDao") JpaRepository<NewChat, Integer> dao, NewChatDao newChatDao, FigureDataDao figureDataDao, FigureData2Dao figureData2Dao) {
        super(dao);
        this.newChatDao = newChatDao;
        this.figureDataDao = figureDataDao;
        this.figureData2Dao = figureData2Dao;
    }


    public ArrayList<NewChat> getChatMsgByNameAndDate(String name, String date) {
        return newChatDao.getChatMsgByNameAndDate(name, date);
    }

    public void addNewChat(NewChat newChat) {
        newChatDao.save(newChat);
    }

    public ArrayList<NewChat> getAllChatMsgByConsultantName(String name) {
        return newChatDao.getAllChatMsgByConsultantName(name);
    }

    public void updateNewChatComment(Integer id, String content) {
        newChatDao.updateNewChatComment(id, content);
    }

    public String getEndTimeById(Integer id) {
        return newChatDao.getEndTimeById(id);
    }

    public ArrayList<NewChat> getAllMsg() {
        return newChatDao.getAllMsg();
    }

    public NewChat getRecentMsg() {
        return newChatDao.getRecentMsg();
    }

    public String getRecentMsgEndTime() {
        return newChatDao.getRecentMsgEndTime();
    }

    public void updateHoldTimeByName(String name, String hold_time) {
        newChatDao.updateHoldTimeByName(name, hold_time);
    }

    public void updateHoldTimeByChatID(Integer id, String hold_time) {
        newChatDao.updateHoldTimeByChatID(id, hold_time);
    }

    public ArrayList<FigureData> getAllConsultNumberLimitK(String month, Integer k) {
        return figureDataDao.getAllConsultNumberLimitK(month, k);
    }

    public ArrayList<FigureData2> gettodayConsultNumberLimitK(String month, Integer day, Integer k) {
        return figureData2Dao.gettodayConsultNumberLimitK(month, day, k);
    }

}
